﻿using System;
using System.Collections.Concurrent;
using System.Threading;
using K9Nano.Caching;
using Microsoft.Extensions.Caching.Memory;

namespace Microsoft.Extensions.DependencyInjection
{
    public static class MemoryExtensions
    {
        public static IServiceCollection AddK9NanoMemoryCache(this IServiceCollection services, Action<MemoryCacheOptions> setupAction)
        {
            services.AddMemoryCache(setupAction);
            services.AddSingleton<ICache, DefaultMemoryCache>();
            return services;
        }

        public static IServiceCollection AddK9NanoMemoryCache(this IServiceCollection services)
        {
            services.AddMemoryCache();
            services.AddSingleton<ICache, DefaultMemoryCache>();
            return services;
        }
    }
}
